package 开始的剑指offer8月.双指针;
// https://leetcode-cn.com/problems/diao-zheng-shu-zu-shun-xu-shi-qi-shu-wei-yu-ou-shu-qian-mian-lcof/
public class 剑指Offer21调整数组顺序使奇数位于偶数前面0825 {
    class Solution {
        public int[] exchange(int[] nums) {
            int n = nums.length;
            int[] res = new int[n];
            int index = 0;
            for(int num : nums){
                if(num % 2 == 1){
                    res[index++] = num;
                }
            }
            for(int num : nums){
                if(num % 2 == 0){
                    res[index++] = num;
                }
            }
            return res;
        }
    }


}
